package controlLayer;
import java.util.List;

import modelLayer.*;
import modelLayer.Class;


public class ClassCtr {

	//private static int counter = 1;
	//private Class cl;
	private ClassCon classCon;
	
	public ClassCtr(){
		setClassCon(classCon);
	}
	
	
	public void createClass(String name, String classOf, Teacher classTeacher){
		Class cl = new Class(name, classOf, classTeacher);
		classCon.addClass(cl);
	}
	
	public void createTeachingBlock(Class cls, String subjectName, int number, String classRoom){
		int counter = 1;
		SubjectCon subjectCon = SubjectCon.getInstance();
		Subject s = subjectCon.findSubject(subjectName);
		
		ClassRoomCon crCon = ClassRoomCon.getInstance();
		ClassRoom cr = crCon.findByName(classRoom);
		
		//number is the number of lessons/subject/week. In later implementations it should be number of lessons/year
		//in later implementations should number in the loop be derived from number of lessons/year
		for (int i = 0; i < number; i++) {
			TeachingBlock tb = new TeachingBlock(cls, s, cr);
			tb.setID(cls.getClassName().substring(0, 1) + subjectName.substring(0, 3)+ "" + counter);
			++counter;
			cls.addTeachingBlock(tb);
		}
		
	}
	
	public Class findClass(String name){
		return classCon.findClassByName(name);
	}

//	/**
//	 * @return the cl
//	 */
//	public Class getCl() {
//		return cl;
//	}
//
//	/**
//	 * @param cl the cl to set
//	 */
//	public void setCl(Class cl) {
//		this.cl = cl;
//	}

	/**
	 * @return the classCon
	 */
	public ClassCon getClassCon() {
		return classCon;
	}

	/**
	 * @param classCon the classCon to set
	 */
	public void setClassCon(ClassCon classCon) {
		this.classCon = ClassCon.getInstance();
	}

}
